package com.puzzlebazar.client.squaregrid.view;

import com.puzzlebazar.client.util.Recti;
import com.puzzlebazar.client.util.Vec2i;

public class CellHighlighterOutline implements CellHighlighter {

	private final DrawableLayer layer;
	private final String style;
	private final String name;
	
	private int pixelSize = 3;
	
	/**
	 * Create an object that is able to highlight cells of a square grid by outlining
	 * the cell.
	 * 
	 * @param layer The layer into which to put drawables resulting from highlighting
	 * @param style The style to use for highlighting  (can be a space separated list)
	 * @param name The name to use for highlighting drawables
	 */
	public CellHighlighterOutline( DrawableLayer layer, String style, String name ) {
		this.layer = layer;
		this.style = style;
		this.name = name;
	}
	
	
	@Override
	public void highlightCell(Vec2i loc) throws Exception {
		DrawableUtils.addEdgeRectangle( new Recti(loc.x,loc.y,1,1), layer, style, name, pixelSize);
		
	}

	@Override
	public void highlightCells(Vec2i loc1, Vec2i loc2) throws Exception {
		DrawableUtils.addEdgeRectangle( loc1, loc2, layer, style, name, pixelSize);
	}
	
	@Override
	public void unhighlightCell(Vec2i loc) throws Exception {
		DrawableUtils.removeEdgeRectangle( new Recti(loc.x,loc.y,1,1), layer, name );
	}

	@Override
	public void unhighlightCells(Vec2i loc1, Vec2i loc2) throws Exception {	
		DrawableUtils.removeEdgeRectangle( loc1, loc2, layer, name );
	}

	@Override
	public void unhighlightAllCells() {
		DrawableUtils.removeEdgeRectangle( layer, name );
	}
	
	/**
	 * Sets the size, in pixel, of the outline.
	 * 
	 * @param pixelSize The size, in pixel
	 */
	public void setPixelSize( int pixelSize ) {
		this.pixelSize = pixelSize;
	}
}
